<template>
	<view class="page">
		<view class="searchBox">
			<view class="inputBox">
				<view class="inputRow" style="" v-if="!roomId" >
					<view class="label">
						{{language.scoreRecord.label1}}:
					</view>
					<view class="val">
							<u-input v-model="params.roomName" :placeholder="language.scoreRecord.tip1"></u-input>
					</view>
				</view>
				<view class="inputRow">
					<view class="label">
						{{language.scoreRecord.label2}}:
					</view>
					<view :class="params.sdate ? 'val' : 'emty'" @click="sdateShow=true">
						{{params.sdate ? params.sdate : language.scoreRecord.label2 }}
					</view>
				</view>
				<view class="inputRow">
						<view class="label">
							{{language.scoreRecord.label3}}:
						</view>
						<view :class="params.edate ? 'val' : 'emty'" @click="edateShow=true">
							{{params.edate ? params.edate : language.scoreRecord.label2 }}
						</view>
				</view>
			</view>
			<view class="btnBox">
				<view class="btn"  @click="goSearch">
					{{language.scoreRecord.search}}
				</view>
			</view>
			
		</view>
		
			<scrollYBox styleText="height: calc( 100vh - 360rpx );" @scrolltolower="scrolltolower" :list="list">
						<template>
							<view style="padding-bottom: 50rpx;">
								<view class="boxItem" v-for="(item,index) in list" :key="index">
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{language.scoreRecord.label4}}
											</view>
											<view class="val">
												{{item.scoreDate  | emptyStr }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.scoreRecord.label1}}
											</view>
											<view class="val" >
												{{item.roomCode  | emptyStr }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.scoreRecord.label5}}
											</view>
											<view class="val" style="color: #5ac725;">
												{{item.totalScore  | emptyNum }}
											</view>
										</view>
									</view>
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{language.scoreRecord.label6}}
											</view>
											<view class="val">
												{{item.healthScore  | emptyNum }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.scoreRecord.label7}}
											</view>
											<view class="val">
												{{item.noonScore  | emptyNum }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.scoreRecord.label8}}
											</view>
											<view class="val">
												{{item.nightScore  | emptyNum }}
											</view>
										</view>
									</view>
								</view>
							</view>
						</template>
					</scrollYBox>
	
		<u-datetime-picker
		    :show="sdateShow" ref="datetimePicker" v-model="sdate" 
		    mode="date"  @cancel="sdateShow=false" @confirm="sdateConfirm"
		       ></u-datetime-picker>
		<u-datetime-picker
			:show="edateShow" ref="datetimePicker" v-model="edate" 
			mode="date"  @cancel="edateShow=false" @confirm="edateConfirm"
	       ></u-datetime-picker>
	</view>
</template>

<script>
	import {dormScoreListApi,dormScoreMinApplistApi} from '@/common/api/commonApi/dormApi.js'
	export default {
		data() {
			return {
				list:[
				],
				params:{
					pageNo : 1,
					pageSize : 10,
					sdate : '',
					edate : '',
					roomName : '',
				},
				sdate: Number(new Date()),
				edate: Number(new Date()),
				sdateShow : false,
				edateShow : false,
				total : 0,
				roomId: '',
				
			}
		},
		components:{
		},
		methods: {
			handleDetail(item){
				this.goPage('/pages/componentsC/safe/accessRecordDetail',{id:1})
			},
			scrolltolower(){
				if(this.total == this.list.length){
					return this.setMessage('没有更多了')
				}
				this.params.pageNo ++
				this.getList()
			},
			goSearch(){
				this.params.pageNo = 1 
				this.getList()
			},
			sdateConfirm(e){
				let date = this.dateformat(e.value).split(' ')[0]
				this.params.sdate = date
				console.log(this.params.sdate);
				this.sdateShow = false
			},
			edateConfirm(e){
				let date = this.dateformat(e.value).split(' ')[0]
				this.params.edate = date
				this.edateShow = false
			},
			getList(){
				let params = this.params
				if(this.roomId){
					params.roomId = this.roomId
					dormScoreListApi(params).then(res=>{
						if(params.pageNo==1) this.list = []
						this.list = this.list.concat(res.result.records)
						this.total = res.result.total
					})
				}else{
					// params.sdate = params.sdate
					// params.edate = params.edate
					// delete params.sdate
					// delete params.edate
					dormScoreMinApplistApi(params).then(res=>{
						if(params.pageNo==1) this.list = []
						this.list = this.list.concat(res.result.pageList.records)
						this.total = res.result.pageList.total
					})
				}
				
				
			},
			goSearch(){
				this.params.pageNo = 1
				this.getList()
			}
			
		},
		onLoad() {
			this.setPageTitle(this.language.scoreRecord.title)
			if(this.$Route.query.id){
				this.roomId = this.$Route.query.id
			}
			this.getList()
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #f1f1f1;
	// height: 100vh;
	.searchBox{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 20rpx;
		border-bottom: 1px solid #f1f1f1;
		margin: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		.inputBox{
			flex: 1;
			padding-right: 30rpx;
			.inputRow{
				height: 80rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				padding-left: 20rpx;
				.label{
					color: #191919;
					margin-right: 30rpx;
				}
			}
			.input{
				
			}
			.emty{
				color: #c0c4cc;
			}
			.val{
				
			}
		}
		.btnBox{
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;
			.reset{
				margin-top: 20rpx;
				border: 1px solid #f1f1f1;
				background: #fff !important;
				color: #353535 !important;
			}
			.btn{
				padding: 0 30rpx;
				// width: 110rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #1890ff;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
	
	.boxItem{
			background-color: #fff;
			margin: 20rpx;
			border-radius: 8rpx;
			padding: 10rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(102,102,102,0.15);
			.row{
				margin: 10rpx;
				display: flex;
				.item{
					width: 50%;
					// flex: 1;
				}
				.label{
					color: #969696;
				}
				.val{
					color: #353535;
					font-size: 32rpx;
				}
				.btn{
						padding: 0 30rpx;
						width: 120rpx;
						height: 60rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						background: #1890ff;
						border-radius: 8rpx;
						color: #fff;
				}
			}
		}
		
}
</style>
